package com.tech.cloudapp.biz.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tech.cloudapp.biz.service.IBQuestionPaperService;
import com.tech.cloudapp.db.entity.QuestionPaper;
import com.tech.cloudapp.db.service.QuestionPaperService;
import com.tech.cloudapp.dto.PageDTO;
import com.tech.cloudapp.po.PagePO;
import com.tech.cloudapp.po.QuestionPaperPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Primary
@Service
public class BQuestionPaperServiceImpl implements IBQuestionPaperService {

    @Autowired
    private QuestionPaperService questionPaperServiceImpl;

    @Override
    public List<QuestionPaper> list(QuestionPaper questionPaper) {
        QueryWrapper<QuestionPaper> questWapper = new QueryWrapper();
        questWapper.eq("classify_id",questionPaper.getClassifyId());
        List list = questionPaperServiceImpl.list(questWapper);
        if(list == null)
        {
            list = new ArrayList();
        }
        return list;
    }

    @Override
    public PageDTO page(QuestionPaperPO questionPaperPO) {
        //获取数据记录总数
        QueryWrapper<QuestionPaper> questWapper = new QueryWrapper();
        questWapper.eq("classify_id",questionPaperPO.getClassifyId());
        PageDTO<QuestionPaper> pageDTO = new PageDTO();
        pageDTO.setCurrent(questionPaperPO.getPage());
        pageDTO.setSize(questionPaperPO.getPageSize());
        PageDTO<QuestionPaper> page = questionPaperServiceImpl.page(pageDTO, questWapper);
        return page;
    }
}
